// 有⼀个停⻋⼩弟管理着两个停⻋场，他的停⻋策略是把⻋停到空位最少的停⻋场
class park {
  constructor(max1,max2){
    this.max1 = max1;
    this.max2 = max2;
    this.carAmount1 = 0;
    this.carNumberList1 = [];
    this.carAmount2 = 0;
    this.carNumberList2 = [];
  }
  parking(carNumber){
    if((this.carAmount1 >= max1) && (this.carAmount2 >= max2)){
      console.log("全部已停满")
      return;
    }
    if(this.carAmount1 < this.carAmount2){
      this.carAmount1 += 1;
      this.carNumberList1 = [...this.carNumberList1,carNumber];
      return;
    }
    if(this.carAmount2 < this.carAmount1){
      this.carAmount2 += 1;
      this.carNumberList2 = [...this.carNumberList2,carNumber];
      return;
    }
  }
  pickUp(carNumber){
    if(this.carNumberList1.find(i => i === carNumber)){
      this.carAmount1 -= 1;
      this.carNumberList1 = this.carNumberList1.filter(i => i !== carNumber);
      return;
    }
    if(this.carNumberList2.find(i => i === carNumber)){
      this.carAmount2 -= 1;
      this.carNumberList2 = this.carNumberList2.filter(i => i !== carNumber);
      return;
    }
    console.log('找不到该车')
  }
}
const Park1 = new park(100,200)
Park1.parking('沪A123123')
Park1.pickUp('沪A123123')